home *** CD-ROM | disk | FTP | other *** search
- unit TblTestU;
-
- interface
-
- uses
- WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Menus, ExtCtrls;
-
- type
- TMainForm = class(TForm)
- lstDataFields: TListBox;
- lstMethods: TListBox;
- Label1: TLabel;
- Label2: TLabel;
- Bevel1: TBevel;
- MainMenu1: TMainMenu;
- File1: TMenuItem;
- Exit1: TMenuItem;
- procedure FormCreate(Sender: TObject);
- procedure ListBoxMouseMove(Sender: TObject;
- Shift: TShiftState; X, Y: Integer);
- procedure Exit1Click(Sender: TObject);
- procedure lstDataFieldsDblClick(Sender: TObject);
- procedure lstMethodsDblClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- MainForm: TMainForm;
-
- implementation
-
- uses TblInfo;
-
- {$R *.DFM}
-
- procedure TMainForm.FormCreate(Sender: TObject);
- begin
- GetMethodNames(Self.ClassType, lstMethods.Items);
- GetDataFieldNames(Self.ClassType, lstDataFields.Items);
- lstDataFields.Perform(lb_SetHorizontalExtent, 250, 0);
- lstMethods.Perform(lb_SetHorizontalExtent, 300, 0);
- end;
-
- procedure TMainForm.ListBoxMouseMove(Sender: TObject;
- Shift: TShiftState; X, Y: Integer);
- begin
- {$ifdef Win32}
- with (Sender as TListBox) do
- begin
- ShowHint := False;
- Application.ProcessMessages;
- ItemIndex := Perform(lb_ItemFromPoint, 0, MakeLong(X, Y));
- if (ItemIndex >= 0) and (ItemIndex < Items.Count) then
- begin
- Hint := Items[ItemIndex];
- ShowHint := True
- end
- end
- {$endif}
- end;
-
- procedure TMainForm.Exit1Click(Sender: TObject);
- begin
- Application.Terminate
- end;
-
- procedure TMainForm.lstDataFieldsDblClick(Sender: TObject);
- const
- Msg = 'FieldAddress says %s lives at $%p, $%x bytes into this object';
- var
- S: String;
- begin
- with Sender as TListBox do
- begin
- { The listbox is showing some nicely formated string. }
- { Need the data field name only. }
- { Can get this from the field table entry record }
- S := PFieldTableEntry(Items.Objects[ItemIndex])^.Name;
- MessageDlg(
- Format(Msg, [S, Self.FieldAddress(S),
- Longint(Self.FieldAddress(S)) - Longint(Self)]),
- mtInformation, [mbOk], 0)
- end
- end;
-
- procedure TMainForm.lstMethodsDblClick(Sender: TObject);
- const
- Msg = 'MethodAddress says %s lives at address $%p';
- var
- S: String;
- begin
- with Sender as TListBox do
- begin
- { The listbox is showing some nicely formated string. }
- { Need the method name only. }
- { Can get this from the method table entry record }
- S := PMethodTableEntry(Items.Objects[ItemIndex])^.Name;
- MessageDlg(
- Format(Msg, [S, Self.MethodAddress(S)]),
- mtInformation, [mbOk], 0)
- end
- end;
-
- end.
-